import { hideToast, showToast } from "@tarojs/taro";

class Toast {
    show(
        content: string,
        icon?: "success" | "error" | "loading" | "none" | undefined,
        successCallback?: () => void,
        timer?: number
    ) {
        showToast({
            title: content,
            mask: true,
            icon,
            success: () => {
                setTimeout(() => {
                    if (typeof successCallback === "function") successCallback();
                }, timer ?? 1500)
            }
        }).then()

    }

    hide() {
        hideToast()
    }
}

export default new Toast()
